import axios from 'axios';
let base = '';
base = window.g.url;


axios.interceptors.request.use(
	(config) => {
		//	let token = Vue.$cookies.get('token');

		config.headers['Access-Control-Allow-Origin'] = '*';
		config.headers['Access-Control-Allow-Methods'] = 'GET,POST,PUT,OPTIONS';
		config.headers['Content-Type'] = 'application/json; charset=utf-8';


		return config;
	},
	(err) => {
		return Promise.reject(err);
	}
);
//登录
export const dologin = (params) => {
	return axios.post(`${base}/users/dologin`, params).then((res) => res.data);
};
//水果查询所有
export const checkLikeList = (params) => {
	return axios.post(`${base}/checkLike?pageNum=${params.pagnum}&limit=${params.limit}`, params).then((res) => res.data);
};
//水果修改
export const saveOrUpdateMeager = (params) => {
	return axios.post(`${base}/saveOrUpdateMeager/`, params).then((res) => res.data);
};
//水果商城删除
export const delFruits = id => {
	return axios
		.delete(`${base}/delFruits/${id}`)
		.then(res => res.data)
}
//所有订单
export const fruitsSorderAll = (params) => {
	// debugger
	return axios.post(`${base}/fruitss/orderAll`).then((res) => res.data);
};
//用户所有
export const getUserAllList = (params) => {
	return axios.post(`${base}/users/getUserAll?pageNum=${params.pagnum}&limit=${params.limit}&userName=${params.userName}`, params).then((res) => res.data);
};
//添加用户
export const saveOrUpdateUser = (params) => {
	return axios.post(`${base}/users/saveOrUpdateUser`, params).then((res) => res.data);
};
// 删除用户
export const delUerParams = uid => {
	return axios
		.delete(`${base}/users/delUser/${uid}`)
		.then(res => res.data)
}
//订单查询
export const orderByName = params => {
	return axios
		.post(`${base}/fruitss/orderByName?userName=${params.userName}`)
		.then(res => res.data)
}



